<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    
    <!-- 
	<sumario>
	<objetivo>"Rastreabilidade"</objetivo>
	<autor>EDUARDO SANTOS DE OLIVEIRA</autor>
	<versao>1.0.0.0</versao>
	<data_criacao> 04.10.2013 </data_criacao>
	<data_ultima_alteracao> N/A </data_ultima_alteracao>
	<requisito_afetado> N/A </requisito_afetado>
	<descricao> Pagina de Pesquisa de Andares </descricao>
	</sumario>
    -->              

    <ui:composition template="/templates/interna.xhtml">

	<ui:define name="breadcrumb">

	    <h:form>

		<p:breadCrumb>
		    <p:menuitem value="#{msg.principal}"/>
		    <p:menuitem value="#{msg.menuCadastros}"/>
		    <p:menuitem value="#{msg.subMenuTabelasBasicas}"/>
		    <p:menuitem value="#{msg.subMenuAndares}"/>
		    <p:menuitem value="#{msg.andarConsultar}"/>
		</p:breadCrumb>

	    </h:form>    

	</ui:define>

	<ui:define name="corpo">

	    <h:form>
                
                <style>
                    .info-qtd-registros{
                        float: right !important; 
                        margin-right: 2.3em; 
                        margin-top: 7px; 
                        vertical-align: bottom;
                    }
                </style> 
                
                <p:ajaxStatus onstart="painelStatus.show();" onsuccess="painelStatus.hide();"/>

		<p:fieldset id="fsDadosPrincipais" legend="#{msg.andarDadosAndar}">
		    
                    <h:panelGrid columns="2">
			
                        <h:panelGrid columns="1">
			    <p:outputLabel value="#{msg.andarNumero}" for="itNumero" />
                            <p:inputText id="itNumero" maxlength="3" value="#{consultarAndar.parametrosConsulta.numero}" style="width: 76em" onkeydown="return somenteNumero(event)"/>
			</h:panelGrid>
                        
			<h:panelGrid columns="1">
			    <p:outputLabel value="#{msg.andarAtivo}" for="somAtivo"/>
                            <p:selectOneMenu id="somAtivo" value="#{consultarAndar.parametrosConsulta.ativo}">
                                <f:selectItems value="#{consultarAndar.listaSimNao}"/>
			    </p:selectOneMenu>
			</h:panelGrid>
                        
		    </h:panelGrid>
		    
                    <p:spacer width="5" height="20"/>
		    
                    <p:commandButton value="#{msg.pesquisar}"
				     icon="ui-icon-search"
				     action="#{consultarAndar.pesquisar}"
                                     process="@form"
                                     update="@form"
                                     style="width: 13em"
                                     oncomplete="dtAndares.getPaginator().setPage(0)"/>
		    
                    <p:spacer width="5"/>
                    
                    <p:commandButton value="#{msg.limparCampos}"
                                     action="#{consultarAndar.limparCampos()}"
                                     icon="ui-icon-clear"
                                     update="@form"
                                     style="width: 13em"/>
                    
                    <p:spacer width="5"/>                    
		    
                    <p:commandButton value="#{msg.novo}" 
				     action="#{manterAndar.setup}"
				     icon="ui-icon-plusthick" 
				     ajax="false"
				     rendered="#{loginUsuario.possuiPrivilegio('CADASTRAR_ANDAR_MANTER')}"
                                     style="width: 13em"/>
		    
                    <p:spacer width="5" rendered="#{loginUsuario.possuiPrivilegio('CADASTRAR_ANDAR_MANTER')}"/>
		    
                    <p:commandButton value="#{msg.voltar}" 
				     action="#{consultarAndar.voltar}" 
				     ajax="false" 
				     icon="ui-icon-arrowreturnthick-1-w"
				     immediate="true"
                                     style="width: 13em"/>	
                    
                    <h:outputText id="otTotalAndares" value="#{msg.andar_andares_encontrados}: #{consultarAndar.rowCount}" rendered="#{consultarAndar.rowCount > 0}" styleClass="texto-negrito-11 info-qtd-registros"/>
                    
		</p:fieldset>
		
		<div class="espacamento"/>

		<p:fieldset legend="#{msg.andar_lista_andares}" 
                            rendered="#{not empty consultarAndar.andarDataModel}">

		    <p:dataTable id="dtAndares" 
				 value="#{consultarAndar.andarDataModel}"
				 var="andar"
				 rows="#{consultarAndar.registrosPorPagina}"
				 rowsPerPageTemplate="#{consultarAndar.linhasPorPagina}"
				 paginator="true"
				 paginatorPosition="bottom"
				 lazy="true"
				 emptyMessage="#{msg.nenhumRegistroEncontrado}"
                                 widgetVar="dtAndares">

                        <p:column headerText="#{msg.andarNumero}" style="width:65%" sortBy="#{andar.numero}">
			    #{andar.numero}
			</p:column>

                        <p:column headerText="#{msg.andarAtivo}" style="text-align: center; width:20%" sortBy="#{andar.ativo}">
			    #{andar.ativo ? 'SIM' : 'NÃO'}
			</p:column>
			
			<p:column headerText="#{msg.acoes}" style="width:15%; text-align: center">
                            
                            <p:commandButton id="btDetalharAndar" icon="ui-icon-search" action="#{manterAndar.detalhar}" ajax="false" title="#{msg.visualizar}">
				<f:setPropertyActionListener value="#{andar.id}" target="#{manterAndar.idAndarSelecionado}"/>
			    </p:commandButton>
                            
                            <p:commandButton id="btExcluirAndar" icon="ui-icon-closethick" title="#{msg.excluir}" onclick="pnConfirmacao.show()" rendered="#{loginUsuario.possuiPrivilegio('CADASTRAR_ANDAR_MANTER')}">
				<f:setPropertyActionListener value="#{andar.id}" target="#{consultarAndar.idAndar}"/>
			    </p:commandButton>
                            
			</p:column>
                        
                        <f:facet name="footer">
                            <div align="right">
                                <p:commandButton value="#{msg.exportar}"
                                                 action="#{consultarAndar.exportarPesquisaXLS}"
                                                 icon="excel"
                                                 immediate="true"
                                                 ajax="false"/>                            
                            </div>
                        </f:facet>                                                

		    </p:dataTable>

		</p:fieldset>

	    </h:form>

	    <ui:include src="/restrito/painel_confirmacao.xhtml">
		<ui:param name="id" value="pnConfirmacao"/>
		<ui:param name="mensagem" value="#{msg.deseja_excluir}"/>
		<ui:param name="bean" value="#{consultarAndar}"/>
		<ui:param name="action" value="excluir"/>
	    </ui:include>

	</ui:define>

    </ui:composition>

</html>
